InitializeCriticalSection (MYCS) before the program starts or creates a thread;//Initialize critical sectionDelete it deletecriticalsection (MYCS) After the end of the program or all threads;//Delete a critical sectionadd EnterCriticalSection (MYCS) where you want to synchronize in the thread;//Enter the critical section Try //Program Code finallyleav
Trtlcriticalsection is a struct, defined in a Windows cell; initializecriticalsection, EnterCriticalSection, LeaveCriticalSection, deletecriticalsection and so on these several kernel32.dll in the critical section operation API parameters; Tcriticalsection is the class implemented in the SYNCOBJS unit, It encapsulates the above critical section Operations API functions, simplifying and facilitating the use of Delphi, such as Tcriticalsection.enter, which calls the EnterCriticalSection API funct
, Tcriticalsection.leave, etc., by invoking the API function of the response above.The simplest and most efficient way to use a critical section is in many ways of thread synchronization (minimum CPU time)Use the critical section code as follows:Declare a global variable of type trtlcriticalsection firstVarMycs:trtlcriticalsection;Before the program starts or creates a thread, initialize theInitializeCriticalSection (MYCS);//Initialize critical sectio
ORACLE segment:First, create a PACKAGE and package body in ORACLE, and define the function and the returned result set of the stored procedure.1: Create a PACKAGE:Create or replace package SCOTT. pk_wtIsType mytype is ref cursor;Procedure p_wt (mycs out mytype );Function f_get (str in varchar2)Return varchar2;End;/Note: PACKAGE is just a declaration. Here we define a stored procedure to return a collection and a function to return a string.
2: Create
Trtlcriticalsection is a struct, defined in a Windows cell; initializecriticalsection, EnterCriticalSection, LeaveCriticalSection, deletecriticalsection and so on these several kernel32.dll in the critical section operation API parameters; Tcriticalsection is the class implemented in the SYNCOBJS unit, It encapsulates the above critical section Operations API functions, simplifying and facilitating the use of Delphi, such as Tcriticalsection.enter, which calls the EnterCriticalSection API funct
Oracle segment:First, create a package and package body in Oracle, and define the function and the returned result set of the stored procedure.1: Create a package:Create or replace package Scott. pk_wtIsType mytype is ref cursor;Procedure p_wt (MYCS out mytype );Function f_get (STR in varchar2)Return varchar2;End;/Note: package is just a declaration. Here we define a stored procedure to return a collection and a function to return a string.
2: Creat
The stored procedure of Oracle returns the record set, and finds that the two Oracle segments are the same, but the C # section is slightly different and put up. I prefer to use the first one. C # Call the Oracle stored procedure to return result sets and functions Oracle segment:First, create a package and package body in Oracle, and define the function and the returned result set of the stored procedure.1: Create a package:Create or replace package Scott. pk_wtIsType mytype is ref cursor;
oracle| Stored Procedures | functions
Oracle segment:First, the package and package body are established in Oracle, where functions and stored procedures are defined to return the result set.1: Establish package:CREATE OR REPLACE Package SCOTT.PK_WTIsType MyType is REF CURSOR;Procedure P_WT (Mycs out MyType);function F_get (str in VARCHAR2)return VARCHAR2;End/Description: In fact, package is just a statement. Here we define a stored procedure to retur
Almost every textbook is written in this way, and when a class is instantiated, the constructor is bound to execute, and the destructor is bound to execute when the class is freed. It seems to be in people's minds that constructors and destructors, like twins, perform constructors and are bound to perform destructors ...
Today, I did an experiment to completely overturn the theory. The code is as follows:
#include "stdafx.h"using namespace std;class mycs
Oracle segment:
First, the package and package body are established in Oracle, where functions and stored procedures are defined to return the result set.
1: Establish package:
CREATE OR REPLACE package SCOTT.pk_wt is type mytype is ref cursor; procedure p_wt( mycs out mytype ); function f_get( str in var char2 ) return var char2; end;/
Description: In fact, package is just a statement. Here we define a stored procedure that returns a compilation
% type; beginselect hiredate into bedate from emp where empno = id; return bedate; end fun_re_date; end pack_op;
Example 8: Call the process and function exec pack_op.pro_print_ename (7900); exec pack_op.pro_print_sal (7900); select pack_op.fun_re_date (7900) from dual; Example 9: demonstrate how to create a package with a cursor in a package
create or replace package pack_emp iscursor cur_emp return emp%rowtype;procedure pro_cur;end pack_emp;
Create a package subject
Create or replace package
|', the salary is good, and a general manager is required ');End if;End loop;End pro_cur;End pack_emp;
Call the procedure in the package to call the cursor in the packageExec pack_emp.pro_cur;
Example 10: The stored procedure returns the cursor's subroutine package (this package returns r_cur cursor)Create or replace package Scott. pk_wtIsType mytype is ref cursor;Procedure p_wt (MYCS out mytype );End;
Create or replace package body Scott. pk_wtIsPro
rec_emp.salCall the procedure in the package to invoke the cursor in the package exec pack_emp.pro_cur;Example 10: A stored procedure returns the cursor child package (This package returns a r_cur cursor) CREATE OR REPLACE scott.pk_wt is the type mytype is REF CURSOR; Procedure P_WT (Mycs out MyType); EndCREATE OR REPLACE Package BODY scott.pk_wt are procedure p_wt (Mycs out MyType) is R_cur MyType; Begin
and rec_emp.sal Dbms_output.put_line ('employee salary: '| rec_emp.sal |', general salary, strive for a department manager to do it ');ElseDbms_output.put_line ('employee salary: '| rec_emp.sal |', the salary is good, and a general manager is required ');End if;End loop;End pro_cur;End pack_emp;
Call the procedure in the package to call the cursor in the packageExec pack_emp.pro_cur;
Example 10: The stored procedure returns the cursor's subroutine package (this package returns r_cur cursor)Crea
department manager to do it ');ElseDbms_output.put_line ('employee salary: '| rec_emp.sal |', the salary is good, and a general manager is required ');End if;End loop;End pro_cur;End pack_emp;
Call the procedure in the package to call the cursor in the packageExec pack_emp.pro_cur;
Example 10: The stored procedure returns the cursor's subroutine package (this package returns r_cur cursor)Create or replace package Scott. pk_wtIsType mytype is ref cursor;Procedure p_wt (
,Pagecount in number,Pagenumber in number,Sqlcondition in varchar2,Icount out number,MYCS out cur_type );End;Next, create a package subject that includes the declared Implementation of the stored procedureCreate or replace package body jisen. TestIsProcedure pageprocedure(Sqltext in varchar2,Pagecount in number,Pagenumber in number,Sqlcondition in varchar2,Icount out number,MYCS out cur_type)AsTempsql varch
Cur_emp%notfound; If rec_emp.salCall the procedure in the package to invoke the cursor in the package exec pack_emp.pro_cur;Example 10: A stored procedure returns the cursor child package (This package returns a r_cur cursor) CREATE OR REPLACE scott.pk_wt is the type mytype is REF CURSOR; Procedure P_WT (Mycs out MyType); EndCREATE OR REPLACE Package BODY scott.pk_wt are procedure p_wt (Mycs out MyType) is
Cur_emp; Loop fetch cur_emp into rec_emp; Exit when Cur_emp%notfound; If rec_emp.salCall the procedure in the package to invoke the cursor in the package exec pack_emp.pro_cur;Example 10: A stored procedure returns the cursor child package (This package returns a r_cur cursor) CREATE OR REPLACE scott.pk_wt is the type mytype is REF CURSOR; Procedure P_WT (Mycs out MyType); EndCREATE OR REPLACE Package BODY scott.pk_wt are procedure p_wt (
the system-defined function. Note that the return type of the function parameter must be specified, and the return type of the COMMAND type must also be specified, in addition, there is no difference with General Oracle stored procedures.
C # Call the Oracle return result set:
OracleCommandcmd=newOracleCommand("pk_wt.p_wt",orcn);
cmd.CommandType=CommandType.StoredProcedure;
OracleParameterp1=newOracleParameter("mycs",OracleType.Cursor);
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.